<script setup lang="ts">
import { h, onBeforeMount } from 'vue'
import { useRoute } from 'vue-router'
import router from '@/router'

defineOptions({
  name: 'RedirectComponent',
})
const route = useRoute()
const { params } = route
const targetPath = params.path // 现在这会是一个数组，如 ['menu1', 'Secondary1']

onBeforeMount(() => {
  const finalPath = Array.isArray(targetPath) ? `/${targetPath.join('/')}` : '/'
  router.push(finalPath)
})

const render = () => h('div')
</script>

<template>
  <render />
</template>
